﻿<html>
<head>
    <meta charset="utf-8" />
    <title>Posts Json Data</title>
    <script src="/asset/jquery.min.js"></script>
    <script src="/asset/jquery-jsonview/jquery.jsonview.js"></script>
    <link href="/asset/jquery-jsonview/jquery.jsonview.css" rel="stylesheet" />
</head>
<body>
    <h2>Posts Json Data</h2>
    <button id="collapse-btn">Collapse</button>
    <button id="expand-btn">Expand</button>
    <button id="toggle-btn">Toggle</button>
    <div id="json"></div>
<script>
    var json = {{ JSON.stringify(d) }};;
    $(function() {
        $("#json").JSONView(json, { collapsed: true, nl2br: true, recursive_collapser: true });
        $('#collapse-btn').on('click', function() {
            $('#json').JSONView('collapse');
        });

        $('#expand-btn').on('click', function() {
            $('#json').JSONView('expand');
        });

        $('#toggle-btn').on('click', function() {
            $('#json').JSONView('toggle');
        });
        $("span.string").click(function() {
            var t = $(this);
            var p=  $(this).prev();
            if (p.get(0).innerText == "\"_id\"") {
                var url = ("/news/" + t.get(0).innerText.replace("\"",""));
                location.href = url;
            }
        })
    });
</script>
</body>
</html>